clear;
cover_1=imread('C:/Code/Matlab/HW1_data/cover_1.jpg');
cover_1=single(rgb2gray(cover_1));
peak_thresh=0.5;
edge_thresh=3;

[f,d]=vl_sift(cover_1,'PeakThresh', peak_thresh,'edgethresh', edge_thresh);
C.Location=f(1:2,:)';
figure;
imshow(cover_1,[0,255]);
hold on;
vl_plotframe(f);

ratio_array=[];
for angle=0:15:360
    rotate_i=imrotate(cover_1,angle);
    [f_r,d_r]=vl_sift(rotate_i,'PeakThresh', peak_thresh,'edgethresh', edge_thresh);
    C_rotate.Location=f_r(1:2,:)';
    ratio=MatchPoint(C,C_rotate,size(cover_1),angle);
    ratio_array=[ratio_array,ratio];
    fprintf('%d : %8.5f\n',angle,ratio);
end
createfigure(0:15:360,ratio_array,'SIFT keypoint detector robustness against rotation');
ratio_array2=[];
scale_array=[];
for size_ratio=0:1:8
    scale_size=1.2^size_ratio;
    scale_array=[scale_array,scale_size];
    resize_img=imresize(cover_1,scale_size,'bicubic');
    [f_s,d_s]=vl_sift(resize_img,'PeakThresh', peak_thresh,'edgethresh', edge_thresh);
    C_resize.Location=f_s(1:2,:)';
    ratio=MatchPoint2(C,C_resize,scale_size);
    ratio_array2=[ratio_array2,ratio];
end
createfigure2(scale_array,ratio_array2,'SIFT keypoint detector robustness against scale');